From 5fd4fa3fb388880215d07407b6b790f34483f31e Mon Sep 17 00:00:00 2001 From: "kaf24@firebug.cl.cam.ac.uk" Date: Tue, 7 Jun 2005 08:59:04 +0000 Subject: [PATCH] bitkeeper revision 1.1688 (42a561d8CR-Fck16qBCLCOs9F40q3g) Give the map_dom_mem_cache a better name, and fix a bug in unmap_domain_mem_with_cache() [it shouldn't actually unmap the page!]. The bug was spotted by George Dunlap. Signed-off-by: Keir Fraser --- xen/arch/x86/mm.c | 10 +++++----- xen/arch/x86/shadow.c | 22 +++++++++++----------- xen/include/asm-x86/shadow.h | 12 ++++++------ xen/include/asm-x86/x86_32/domain_page.h | 19 ++++++++++++------- xen/include/asm-x86/x86_64/domain_page.h | 6 +++--- 5 files changed, 37 insertions(+), 32 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index bda7d9725a..797b89ed0c 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -1940,7 +1940,7 @@ int do_mmu_update( struct vcpu *v = current; struct domain *d = v->domain; u32 type_info; - struct map_dom_mem_cache mapcache, sh_mapcache; + struct domain_mmap_cache mapcache, sh_mapcache; LOCK_BIGLOCK(d); @@ -1956,8 +1956,8 @@ int do_mmu_update( (void)get_user(done, pdone); } - init_map_domain_mem_cache(&mapcache); - init_map_domain_mem_cache(&sh_mapcache); + domain_mmap_cache_init(&mapcache); + domain_mmap_cache_init(&sh_mapcache); if ( !set_foreigndom(cpu, foreigndom) ) { @@ -2169,8 +2169,8 @@ int do_mmu_update( } out: - destroy_map_domain_mem_cache(&mapcache); - destroy_map_domain_mem_cache(&sh_mapcache); + domain_mmap_cache_destroy(&mapcache); + domain_mmap_cache_destroy(&sh_mapcache); process_deferred_ops(cpu); diff --git a/xen/arch/x86/shadow.c b/xen/arch/x86/shadow.c index cd71ee48af..60683518d6 100644 --- a/xen/arch/x86/shadow.c +++ b/xen/arch/x86/shadow.c @@ -763,8 +763,8 @@ void free_monitor_pagetable(struct vcpu *v) int set_p2m_entry(struct domain *d, unsigned long pfn, unsigned long mfn, - struct map_dom_mem_cache *l2cache, - struct map_dom_mem_cache *l1cache) + struct domain_mmap_cache *l2cache, + struct domain_mmap_cache *l1cache) { unsigned long phystab = pagetable_get_paddr(d->arch.phys_table); l2_pgentry_t *l2, l2e; @@ -808,14 +808,14 @@ alloc_p2m_table(struct domain *d) struct pfn_info *page, *l2page; l2_pgentry_t *l2; unsigned long mfn, pfn; - struct map_dom_mem_cache l1cache, l2cache; + struct domain_mmap_cache l1cache, l2cache; l2page = alloc_domheap_page(NULL); if ( l2page == NULL ) return 0; - init_map_domain_mem_cache(&l1cache); - init_map_domain_mem_cache(&l2cache); + domain_mmap_cache_init(&l1cache); + domain_mmap_cache_init(&l2cache); d->arch.phys_table = mk_pagetable(page_to_phys(l2page)); l2 = map_domain_mem_with_cache(page_to_phys(l2page), &l2cache); @@ -851,8 +851,8 @@ alloc_p2m_table(struct domain *d) list_ent = page->list.next; } - destroy_map_domain_mem_cache(&l2cache); - destroy_map_domain_mem_cache(&l1cache); + domain_mmap_cache_destroy(&l2cache); + domain_mmap_cache_destroy(&l1cache); return 1; } @@ -2682,7 +2682,7 @@ int shadow_fault(unsigned long va, struct cpu_user_regs *regs) void shadow_l1_normal_pt_update( struct domain *d, unsigned long pa, l1_pgentry_t gpte, - struct map_dom_mem_cache *cache) + struct domain_mmap_cache *cache) { unsigned long sl1mfn; l1_pgentry_t *spl1e, spte; @@ -2707,7 +2707,7 @@ void shadow_l1_normal_pt_update( void shadow_l2_normal_pt_update( struct domain *d, unsigned long pa, l2_pgentry_t gpde, - struct map_dom_mem_cache *cache) + struct domain_mmap_cache *cache) { unsigned long sl2mfn; l2_pgentry_t *spl2e; @@ -2732,7 +2732,7 @@ void shadow_l2_normal_pt_update( void shadow_l3_normal_pt_update( struct domain *d, unsigned long pa, l3_pgentry_t gpde, - struct map_dom_mem_cache *cache) + struct domain_mmap_cache *cache) { BUG(); // not yet implemented } @@ -2742,7 +2742,7 @@ void shadow_l3_normal_pt_update( void shadow_l4_normal_pt_update( struct domain *d, unsigned long pa, l4_pgentry_t gpde, - struct map_dom_mem_cache *cache) + struct domain_mmap_cache *cache) { BUG(); // not yet implemented } diff --git a/xen/include/asm-x86/shadow.h b/xen/include/asm-x86/shadow.h index 6099a6e8a3..08c4339f16 100644 --- a/xen/include/asm-x86/shadow.h +++ b/xen/include/asm-x86/shadow.h @@ -121,25 +121,25 @@ extern void __shadow_sync_all(struct domain *d); extern int __shadow_out_of_sync(struct vcpu *v, unsigned long va); extern int set_p2m_entry( struct domain *d, unsigned long pfn, unsigned long mfn, - struct map_dom_mem_cache *l2cache, - struct map_dom_mem_cache *l1cache); + struct domain_mmap_cache *l2cache, + struct domain_mmap_cache *l1cache); extern void remove_shadow(struct domain *d, unsigned long gpfn, u32 stype); extern void shadow_l1_normal_pt_update(struct domain *d, unsigned long pa, l1_pgentry_t l1e, - struct map_dom_mem_cache *cache); + struct domain_mmap_cache *cache); extern void shadow_l2_normal_pt_update(struct domain *d, unsigned long pa, l2_pgentry_t l2e, - struct map_dom_mem_cache *cache); + struct domain_mmap_cache *cache); #if CONFIG_PAGING_LEVELS >= 3 extern void shadow_l3_normal_pt_update(struct domain *d, unsigned long pa, l3_pgentry_t l3e, - struct map_dom_mem_cache *cache); + struct domain_mmap_cache *cache); #endif #if CONFIG_PAGING_LEVELS >= 4 extern void shadow_l4_normal_pt_update(struct domain *d, unsigned long pa, l4_pgentry_t l4e, - struct map_dom_mem_cache *cache); + struct domain_mmap_cache *cache); #endif extern int shadow_do_update_va_mapping(unsigned long va, l1_pgentry_t val, diff --git a/xen/include/asm-x86/x86_32/domain_page.h b/xen/include/asm-x86/x86_32/domain_page.h index d46f21b67a..c8dcb6003a 100644 --- a/xen/include/asm-x86/x86_32/domain_page.h +++ b/xen/include/asm-x86/x86_32/domain_page.h @@ -27,31 +27,36 @@ extern void *map_domain_mem(unsigned long pa); */ extern void unmap_domain_mem(void *va); -struct map_dom_mem_cache { +#define DMCACHE_ENTRY_VALID 1UL +#define DMCACHE_ENTRY_HELD 2UL + +struct domain_mmap_cache { unsigned long pa; void *va; }; static inline void -init_map_domain_mem_cache(struct map_dom_mem_cache *cache) +domain_mmap_cache_init(struct domain_mmap_cache *cache) { ASSERT(cache != NULL); cache->pa = 0; } static inline void * -map_domain_mem_with_cache(unsigned long pa, struct map_dom_mem_cache *cache) +map_domain_mem_with_cache(unsigned long pa, struct domain_mmap_cache *cache) { ASSERT(cache != NULL); + BUG_ON(cache->pa & DMCACHE_ENTRY_HELD); if ( likely(cache->pa) ) { + cache->pa |= DMCACHE_ENTRY_HELD; if ( likely((pa & PAGE_MASK) == (cache->pa & PAGE_MASK)) ) goto done; unmap_domain_mem(cache->va); } - cache->pa = (pa & PAGE_MASK) | 1; + cache->pa = (pa & PAGE_MASK) | DMCACHE_ENTRY_HELD | DMCACHE_ENTRY_VALID; cache->va = map_domain_mem(cache->pa); done: @@ -60,14 +65,14 @@ map_domain_mem_with_cache(unsigned long pa, struct map_dom_mem_cache *cache) } static inline void -unmap_domain_mem_with_cache(void *va, struct map_dom_mem_cache *cache) +unmap_domain_mem_with_cache(void *va, struct domain_mmap_cache *cache) { ASSERT(cache != NULL); - unmap_domain_mem(va); + cache->pa &= ~DMCACHE_ENTRY_HELD; } static inline void -destroy_map_domain_mem_cache(struct map_dom_mem_cache *cache) +domain_mmap_cache_destroy(struct domain_mmap_cache *cache) { ASSERT(cache != NULL); if ( likely(cache->pa) ) diff --git a/xen/include/asm-x86/x86_64/domain_page.h b/xen/include/asm-x86/x86_64/domain_page.h index 2a59fb1e5e..ae0e6d2413 100644 --- a/xen/include/asm-x86/x86_64/domain_page.h +++ b/xen/include/asm-x86/x86_64/domain_page.h @@ -10,12 +10,12 @@ #define map_domain_mem(_pa) phys_to_virt(_pa) #define unmap_domain_mem(_va) ((void)(_va)) -struct map_dom_mem_cache { +struct domain_mmap_cache { }; -#define init_map_domain_mem_cache(_c) ((void)(_c)) +#define domain_mmap_cache_init(_c) ((void)(_c)) #define map_domain_mem_with_cache(_p,_c) (map_domain_mem(_p)) #define unmap_domain_mem_with_cache(_v,_c) ((void)(_v)) -#define destroy_map_domain_mem_cache(_c) ((void)(_c)) +#define domain_mmap_cache_destroy(_c) ((void)(_c)) #endif /* __ASM_DOMAIN_PAGE_H__ */ -- 2.30.2